import React from 'react'
import { Col, Form, Input, Modal, Row } from 'antd'

const FormItem = Form.Item
const AddUser = ({
                onOk,
                dispatch,
                form: {
                  getFieldDecorator,
                  validateFields,
                  setFieldsValue,
                },
                ...addModalProps,
              }) => {
  addModalProps.onOk = () => {
    validateFields((err, values) => {
      if (!err) {
        onOk(values)
      }
    })
  }

  return (
    <Modal {...addModalProps}>
      <Form layout="horizontal">
        <Row>
          <Col span={10}>
            <FormItem>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="center">
          <Col span={24}>
            <FormItem labelCol={{span: 7}}
                      wrapperCol={{span: 15}}
                      label="手机号或邮箱">
              {getFieldDecorator('keyword', {
                rules: [{required: true, message: '此项必须填写!'}, {whitespace: true}, {pattern: '^(\\w-*\\.*)+@(\\w-?)+(\\.\\w{2,})|(^1\\d{10})', message: '请输入手机号或邮箱！'}],
                initialValue: '',
              })(<Input placeholder="请输入手机号或邮箱"/>)}
            </FormItem>
          </Col>
        </Row>
      </Form>
    </Modal>
  )
}

export default Form.create()(AddUser)
